package com.ruoyi.system.service.impl;

import java.util.Collections;
import java.util.List;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.TbDevice;
import com.ruoyi.system.mapper.TbDeviceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TbAirplaneMapper;
import com.ruoyi.system.domain.TbAirplane;
import com.ruoyi.system.service.ITbAirplaneService;

/**
 * 飞机信息Service业务层处理
 *
 * @author ruoyi
 * @date 2025-07-23
 */
@Service
public class TbAirplaneServiceImpl implements ITbAirplaneService {
    @Autowired
    private TbAirplaneMapper tbAirplaneMapper;


    @Autowired
    private TbDeviceMapper tbDeviceMapper;

    /**
     * 查询飞机信息
     *
     * @param id 飞机信息主键
     * @return 飞机信息
     */
    @Override
    public TbAirplane selectTbAirplaneById(Long id) {
        return tbAirplaneMapper.selectTbAirplaneById(id);
    }

    /**
     * 查询飞机信息列表
     *
     * @param tbAirplane 飞机信息
     * @return 飞机信息
     */
    @Override
    public List<TbAirplane> selectTbAirplaneList(TbAirplane tbAirplane) {
        return tbAirplaneMapper.selectTbAirplaneList(tbAirplane);
    }

    /**
     * 新增飞机信息
     *
     * @param tbAirplane 飞机信息
     * @return 结果
     */
    @Override
    public int insertTbAirplane(TbAirplane tbAirplane) {
        tbAirplane.setCreateTime(DateUtils.getNowDate());
        return tbAirplaneMapper.insertTbAirplane(tbAirplane);
    }

    /**
     * 修改飞机信息
     *
     * @param tbAirplane 飞机信息
     * @return 结果
     */
    @Override
    public int updateTbAirplane(TbAirplane tbAirplane) {
        tbAirplane.setUpdateTime(DateUtils.getNowDate());
        return tbAirplaneMapper.updateTbAirplane(tbAirplane);
    }

    /**
     * 批量删除飞机信息
     *
     * @param ids 需要删除的飞机信息主键
     * @return 结果
     */
    @Override
    public int deleteTbAirplaneByIds(Long[] ids) {
        return tbAirplaneMapper.deleteTbAirplaneByIds(ids);
    }

    /**
     * 删除飞机信息信息
     *
     * @param id 飞机信息主键
     * @return 结果
     */
    @Override
    public int deleteTbAirplaneById(Long id) {
        return tbAirplaneMapper.deleteTbAirplaneById(id);
    }

    @Override
    public int updateStatusById(Long id, Integer status) {
        return tbAirplaneMapper.updateStatusById(id, status);
    }

    @Override
    public List<TbAirplane> selectTbAirplaneLis(TbAirplane tbAirplane) {
        return tbAirplaneMapper.selectTbAirplaneLis(tbAirplane);
    }

    @Override
    public R<List<TbDevice>> selectCanRelDev() {

        return R.ok(tbDeviceMapper.selectCanRelDev());
    }

    @Override
    public int relDevice(String planeCode, Long deviceId) {

        return tbDeviceMapper.updateDevice(planeCode, deviceId) ;
    }

    @Override
    public List<String> listAirpalneCode() {
        return tbAirplaneMapper.listAirpalneCode();
    }

    @Override
    public TbAirplane selectTbAirplaneCode(String planeCode) {
        return tbAirplaneMapper.selectTbAirplaneCode(planeCode);
    }
}
